<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('用户详情')">导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="businessFlag" slot-scope="text">
          <a-tag v-if="text == 1" color="green">是</a-tag>
          <a-tag v-if="text == 0" color="red">否</a-tag>
        </template>
        <template slot="businessLicenseUrl" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="certificationQualificationUrl" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <template>

        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <njt-user-perfect-modal ref="modalForm" @ok="modalFormOk"></njt-user-perfect-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import NjtUserPerfectModal from './modules/NjtUserPerfectModal'

  export default {
    name: 'NjtUserPerfectList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      NjtUserPerfectModal
    },
    data () {
      return {
        description: '用户详情管理页面',
        // 表头
        columns: [
          {
            title: '编号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'用户注册表ID',
            align:"center",
            dataIndex: 'userId'
          },
          {
            title:'注册手机号',
            align:"center",
            dataIndex: 'mobilePhone'
          },
          {
            title:'注册时间',
            align:"center",
            dataIndex: 'registerTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'主体名称',
            align:"center",
            dataIndex: 'companyName'
          },
          {
            title:'法人姓名',
            align:"center",
            dataIndex: 'legalPersonName'
          },
          {
            title:'是否有营业执照 ',
            align:"center",
            dataIndex: 'businessFlag',
            scopedSlots: { customRender: 'businessFlag' }
          },
          {
            title:'营业执照',
            align:"center",
            dataIndex: 'businessLicenseUrl',
            scopedSlots: { customRender: 'businessLicenseUrl' }
          },
          {
            title:'认证资质',
            align:"center",
            dataIndex: 'certificationQualificationUrl',
            scopedSlots: { customRender: 'certificationQualificationUrl' }
          },
          {
            title:'省',
            align:"center",
            dataIndex: 'province'
          },
          {
            title:'市',
            align:"center",
            dataIndex: 'city'
          },
          {
            title:'区/县',
            align:"center",
            dataIndex: 'area'
          },
          {
            title:'乡镇/街道',
            align:"center",
            dataIndex: 'country'
          },
          {
            title:'详细地址',
            align:"center",
            dataIndex: 'detailAddress'
          },
          {
            title:'地址编码',
            align:"center",
            dataIndex: 'addressCode'
          },
          {
            title:'生产类型',
            align:"center",
            dataIndex: 'produceType'
          },
          {
            title:'主体类型',
            align:"center",
            dataIndex: 'mainType'
          },
          {
            title:'行业类型',
            align:"center",
            dataIndex: 'industryType'
          },
          {
            title:'联系电话',
            align:"center",
            dataIndex: 'phoneNumber'
          },
          {
            title:'统一社会信用代码',
            align:"center",
            dataIndex: 'creditCode'
          },
          {
            title:'证件号码',
            align:"center",
            dataIndex: 'idNumber'
          },
          {
            title:'注册资金（万元）',
            align:"center",
            dataIndex: 'registerMoney'
          },
          {
            title:'品牌logo',
            align:"center",
            dataIndex: 'logoUrl'
          },
          {
            title:'照片墙',
            align:"center",
            dataIndex: 'photoWall'
          },
          {
            title:'照片墙介绍',
            align:"center",
            dataIndex: 'photoMsg'
          },
          {
            title:'经度',
            align:"center",
            dataIndex: 'longitude'
          },
          {
            title:'纬度',
            align:"center",
            dataIndex: 'latitude'
          },
          {
            title:'企业成立时间',
            align:"center",
            dataIndex: 'foundTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'审核状态',
            align:"center",
            dataIndex: 'examineStatus'
          },
          {
            title:'审核未通过原因',
            align:"center",
            dataIndex: 'examineMsg'
          },
          {
            title:'审核时间',
            align:"center",
            dataIndex: 'examineTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'省平台密码',
            align:"center",
            dataIndex: 'sptPassword'
          },
          {
            title:'省平台账号',
            align:"center",
            dataIndex: 'sptLoginName'
          },
          {
            title:'是否有省平台权限',
            align:"center",
            dataIndex: 'sptAuth'
          },
          {
            title:'是否同步到成都市该主体信息是否需要同步到成都市',
            align:"center",
            dataIndex: 'isSync'
          },
          {
            title:'删除标记 ',
            align:"center",
            dataIndex: 'delFlag'
          },
          {
            title:'创建人',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title:'创建时间',
            align:"center",
            dataIndex: 'createTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'修改人',
            align:"center",
            dataIndex: 'updateBy'
          },
          {
            title:'更新时间',
            align:"center",
            dataIndex: 'updateTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/user/njtUserPerfect/list",
          delete: "/user/njtUserPerfect/delete",
          deleteBatch: "/user/njtUserPerfect/deleteBatch",
          exportXlsUrl: "/user/njtUserPerfect/exportXls",
          importExcelUrl: "user/njtUserPerfect/importExcel",
          
        },
        dictOptions:{},
      };
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>